<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>回收人员列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.5.3/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../js/jquery.qrcode.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form" id="addproxy1">
    <div class="layui-form-item" style="margin-top: 10px">
        姓名：
        <div class="layui-inline">
            <input class="layui-input" name="name" id="name" autocomplete="off">
        </div>
        号码：
        <div class="layui-inline">
            <input class="layui-input" name="phone" id="phone" autocomplete="off">
        </div>

        <div class="layui-btn-group demoTable" id="demoTable">

            <button class="layui-btn" data-type="reload">搜索</button>
            <button class="layui-btn" data-type="getCheckData">提交</button>
        </div>
    </div>
</form>
<table class="layui-hide" id="merchant" lay-filter="merchant" lay-data="{height: 'full-200', cellMinWidth: 80}"></table>
<script src="../layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/tool.js"></script>
<script type="text/javascript" src="../js/public.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var uid = GetQueryString("id");
    layui.use(['form', 'table', "laydate"], function () {
        var form = layui.form;
        var table = layui.table;
        $ = layui.$;

        //方法级渲染
        table.render({
            elem: '#merchant'
            , url: '/refuse-web/admin/appuserlist'
            , minWidth: 80
            , cols: [
                [
                    {checkbox: true, fixed: true}
                    , {field: 'name', title: '用户名', width: 110, align: 'center'}
                    , {field: 'phone', title: '号码', width: 130, align: 'center'}
                    , {field: 'status', title: '状态', width: 120, align: 'center'}
                    , {
                    field: 'create_time', title: '时间', templet: function (row) {
                        return createTime(row.create_time);
                    }
                }
                    // ,{title:'操作', align:'center', toolbar: '#toolbar'} //这里的toolbar值是模板元素的选择器
                ]
            ]
            , id: 'testReload'
            , page: true
        });

        function createTime(v) {

            var date = new Date(v);
            var y = date.getFullYear();
            var m = date.getMonth() + 1;
            m = m < 10 ? '0' + m : m;
            var d = date.getDate();
            d = d < 10 ? ("0" + d) : d;
            var h = date.getHours();
            h = h < 10 ? ("0" + h) : h;
            var M = date.getMinutes();
            M = M < 10 ? ("0" + M) : M;
            var str = y + "-" + m + "-" + d + " " + h + ":" + M;
            return str;
        }

        // $.ajax({
        //     url:'getxqlist',
        //     type:"post",
        //     data: {
        //         id: 1
        //     },
        //     success:function(d){
        //
        //         let str="";
        //         for(let i of d){
        //             str+=`<option value='${i.id}'>${i.xqname}</option>`;
        //         }
        //         $("#jdname").append(str);
        //         form.render();
        //     }
        // })
//监听工具条
        table.on('tool(merchant)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var uid = obj.data.id; //获得当前行数据
            var refuse_type = obj.data.refuse_type; //获得当前行数据
            var status_type = obj.data.status; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            if (layEvent === 'info') { //修改系统用户别名
                //多窗口模式，层叠置顶
                layer.open({
                    type: 2 //此处以iframe举例
                    , title: '垃圾袋详情'
                    , area: ['1200px', '600px']
                    , shade: 0
                    , maxmin: true
                    , offset: 'auto'
                    , content: 'tobaginfolist?fcode=' + fcode
                    , zIndex: layer.zIndex //重点1
                    , success: function (layero) {
                        layer.setTop(layero); //重点2
                    }
                });

            } else if (layEvent === 'detail') {
                //多窗口模式，层叠置顶
                layer.open({
                    type: 2 //此处以iframe举例
                    , title: '回收员列表'
                    , area: ['1200px', '600px']
                    , shade: 0
                    , maxmin: true
                    , offset: 'auto'
                    , content: 'tobaginfolist?fcode=' + fcode
                    , zIndex: layer.zIndex //重点1
                    , success: function (layero) {
                        layer.setTop(layero); //重点2
                    }
                });


            } else if (layEvent === 'wx') {
                layer.open({
                    type: 2 //此处以iframe举例
                    , title: '添加通道'
                    , area: ['1200px', '600px']
                    , shade: 0
                    , maxmin: true
                    , offset: 'auto'
                    , content: 'zfb.html?uid=' + obj.data.uid + '&istype=20001'
                    , zIndex: layer.zIndex //重点1
                    , success: function (layero) {
                        layer.setTop(layero); //重点2
                    }
                });
            }
        });
        var $ = layui.$, active = {
            getCheckData: function () { //获取选中数据
                //多窗口模式，层叠置顶
                var a = layui.table.checkStatus('testReload');
                var aid = a.data[0].id;
                var name = a.data[0].name;
                var phone = a.data[0].phone;
                $.ajax({
                    type: "post",
                    dataType: "json",
                    url: "/refuse-web/admin/zphsy",
                    async: true,
                    data: {
                        id: uid,
                        name: name,

                        phone: phone,
                        aid: aid
                    },
                    success: function (data) {
                        if (data.code == 0) {
                            alert("成功");
                            layer.closeAll();
                        }
                    },
                    error: function (msg) {
                        alert("服务器请求失败！");
                    }
                });

            },
            getCheckData1: function () { //获取选中数据
                //多窗口模式，层叠置顶
                alert("311");
                var num = null;
                var type = $("#type").val();
                var islq = $("#islq").val();
                var xqid = $("#jdname").val();
                var startTime = $("#startTime").val();
                $.ajax({
                    type: "post",
                    dataType: "json",
                    url: "export",
                    async: true,
                    data: {
                        fcode: num,
                        type: type,
                        islq: islq,
                        xqid: xqid,
                        startTime: startTime
                    },
                    success: function (data) {
                        var map = data;
                        //alert(map.result);
                        if (map.code == 200) {
                            window.location.href = "/ljfl/" + map.result
                        } else {
                            layer.msg(map.msg);
                        }
                    },
                    error: function (msg) {
                        alert("服务器请求失败！");
                    }
                });

            },
            reload: function () {
                var name = $('#name').val();
                var phone = $('#phone').val();
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        name: name,
                        phone: phone
                    }
                });
            }

        };

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
            //防止二次提交
            return false;
        });


    });

    function Reload() {
        window.location.reload()
    };

</script>
<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs" data-method="setTop" lay-event="detail">指派回收员</a>
</script>
</body>
</html>
